package com.hs.utils;

import com.hs.entity.TbUser;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.support.DefaultSubjectContext;

public class ShiroUtils {

    public static TbUser getSessionUser()
    {
        Session session= SecurityUtils.getSubject().getSession();
        SimplePrincipalCollection cll= (SimplePrincipalCollection) session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
        return (TbUser) cll.getPrimaryPrincipal();
    }
}
